<?php

/* @var $this yii\web\View */

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\grid\GridView;
use app\models\SysConfig;
$this->title = '禁止会员登录或解除禁止';
$this->params['breadcrumbs'][] = $this->title;

?>
<div class="page-title">
  <div>
    <h1><i class="fa fa-street-view"></i> 禁止会员登录或解除禁止</h1>
    <!--ul class="breadcrumb side">
      <li><i class="fa fa-home fa-lg"></i></li>
      <li><a href="#">会员管理</a></li>
      <li class="active"><a href="#">禁止会员登录或解除禁止</a></li>
    </ul-->

  </div>
</div>
<div class="card">
  <div class="btn-group">
    <a class="btn btn-info btn-sm" id='forbidall_btn' style='margin:0 1px;'>禁止全部</a>
    <a class="btn btn-info btn-sm" id='unforbidall_btn' style='margin:0 1px;'>解禁全部</a>
    <a class="btn btn-info btn-sm" id='forbid_btn' style='margin:0 1px;'>禁止</a>
    <a class="btn btn-info btn-sm" id='unforbid_btn' style='margin:0 1px;'>解禁</a>
  </div>
  <div style='padding-left:8px;'>
    <div class="radio">
      <label>
          <input name="forbid-tip" id="forbid-tip-wh" type="radio" <?php
            if(SysConfig::FORBID_USER_TIP_WH==$this->context->sysConfig->forbid_tip){
              echo 'checked="true"';
            }
          ?> value="1">系统正在维护中，请稍后访问...
      </label>
    </div>
    <div class="radio">
      <label>
          <input name="forbid-tip" id="forbid-tip-js" type="radio" <?php
            if(SysConfig::FORBID_USER_TIP_JS==$this->context->sysConfig->forbid_tip){
              echo 'checked="true"';
            }
          ?> value="2">系统正在结算收益，请稍后访问...
      </label>
    </div>
  </div>


  <?php
  echo GridView::widget([
  'dataProvider' => $dataProvider,
  'columns' => [
  ['class' => 'yii\grid\CheckboxColumn'],
  ['class' => 'yii\grid\SerialColumn'],
  'realname',
  [
    'header'=>'用户名',
    'content'=>function ($model, $key, $index, $column) {
      return $model->name;
    }
  ],
  [
    'header'=>'手机号',
    'content'=>function ($model, $key, $index, $column) {
      return $model->phone;
    }
  ],
  //'sfzid',
  [
    'header'=>'是否允许登录',
    'content'=>function ($model, $key, $index, $column) {
      return ($model->can_login==1)? 'yes':'no';
    }
  ]


  ],
  'tableOptions' => [
    'class' => 'table'
  ],
  'layout' => "{items}\n{pager}",
  ]);
   ?>

</div>

<?php $this->beginBlock('forbid-js') ?>



  $('#forbid_btn').click(function(){
    var mykeys = $('.grid-view').yiiGridView('getSelectedRows');
    $.ajax({
      url:"<?=Url::toRoute('site/forbiduserajax')?>",
      type:"get",
      datatype:"json",
      cache:false,
      data:{
        keys:mykeys,
        mode:'forbid'
      },
      success:function(data){
         var obj = JSON.parse(data);
         if(obj.errcode===0){
            window.location.href='<?=Url::toRoute('site/forbiduser')?>'+'?key='+(new Date()).valueOf();
         }
      },
      error:function(jqXHR,textStatus,errorThrown){
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
      }
    });
  });
  $('#forbidall_btn').click(function(){
    var mykeys = $('.grid-view').yiiGridView('getSelectedRows');
    $.ajax({
      url:"<?=Url::toRoute('site/forbiduserajax')?>",
      type:"get",
      datatype:"json",
      cache:false,
      data:{
        keys:mykeys,
        mode:'forbidall'
      },
      success:function(data){
         var obj = JSON.parse(data);
         if(obj.errcode===0){
            window.location.href='<?=Url::toRoute('site/forbiduser')?>'+'?key='+(new Date()).valueOf();
         }
      },
      error:function(jqXHR,textStatus,errorThrown){
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
      }
    });
  });
  $('#unforbid_btn').click(function(){
    var mykeys = $('.grid-view').yiiGridView('getSelectedRows');
    $.ajax({
      url:"<?=Url::toRoute('site/forbiduserajax')?>",
      type:"get",
      datatype:"json",
      cache:false,
      data:{
        keys:mykeys,
        mode:'unforbid'
      },
      success:function(data){
         var obj = JSON.parse(data);
         if(obj.errcode===0){
            window.location.href='<?=Url::toRoute('site/forbiduser')?>'+'?key='+(new Date()).valueOf();
         }
      },
      error:function(jqXHR,textStatus,errorThrown){
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
      }
    });
  });
  $('#unforbidall_btn').click(function(){
    var mykeys = $('.grid-view').yiiGridView('getSelectedRows');
    $.ajax({
      url:"<?=Url::toRoute('site/forbiduserajax')?>",
      type:"get",
      datatype:"json",
      cache:false,
      data:{
        keys:mykeys,
        mode:'unforbidall'
      },
      success:function(data){
         var obj = JSON.parse(data);
         if(obj.errcode===0){

            window.location.href='<?=Url::toRoute('site/forbiduser')?>'+'?key='+(new Date()).valueOf();

         }
      },
      error:function(jqXHR,textStatus,errorThrown){
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
      }
    });
  });

  $('#forbid-tip-wh').click(function(){
    $.ajax({
      url:"<?=Url::toRoute('site/forbidusertipajax')?>",
      type:"get",
      datatype:"json",
      cache:false,
      data:{
        mode:'wh'
      },
      success:function(data){
         var obj = JSON.parse(data);
         if(obj.errcode===0){
           //alert('ok');
         }
      },
      error:function(jqXHR,textStatus,errorThrown){
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
      }
    });
  });
  $('#forbid-tip-js').click(function(){
    $.ajax({
      url:"<?=Url::toRoute('site/forbidusertipajax')?>",
      type:"get",
      datatype:"json",
      cache:false,
      data:{
        mode:'js'
      },
      success:function(data){
         var obj = JSON.parse(data);
         if(obj.errcode===0){
           //alert('ok');
         }
      },
      error:function(jqXHR,textStatus,errorThrown){
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
      }
    });
  });

<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['forbid-js'],\yii\web\View::POS_END); ?>
